package com.zxlspace.collection;

import java.util.HashMap;

public class SxtHashSet {

    private static final Object PRESENT = new Object();

    private int size;

    private HashMap map;

    public SxtHashSet() {
        map = new HashMap();
    }

    public void add(Object obj) {
        Object result = map.put(obj, PRESENT);
        if (result == null) {
            size++;
        }
    }

    public int size() {
        return size;
    }

    public static void main(String[] args) {
        SxtHashSet set = new SxtHashSet();
        set.add("123");
        set.add("123");
        set.add("456");
        System.out.println(set.size());
    }
}
